#include <bits/stdc++.h>
using namespace std;
int N;
deque<int> q;
void solve();

int main() {
    cin >> N; int t;
    for (int i = 0; i < N; i++) {
        cin >> t;
        q.push_back(t);
    }
    solve();
    return 0;
}

void solve() {
    int res = 0;
    while (q.size() > 1) {
        if (q.front() == q.back()) {
            q.pop_back(); q.pop_front();
        }
        else if (q.front() < q.back()) {
            int a = q.front(); q.pop_front();
            int b = q.front(); q.pop_front();
            q.push_front(a + b); res++;
        }
        else if (q.front() > q.back()) {
            int a = q.back(); q.pop_back();
            int b = q.back(); q.pop_back();
            q.push_back(a + b); res++;
        }
    }
    cout << res << endl;
}